package com.edou.system.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.apache.ibatis.session.RowBounds;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.edou.base.page.PageResult;
import com.edou.system.dao.ISysTagDao;
import com.edou.system.entity.SysTag;
import com.edou.system.service.ISysTagService;

import com.edou.system.dto.SysTagCondition;

/**
 * 标签
 * @creator     
 * @create-time 2016/5/12 17:21:12
 * @email admin@edou.com
 * @company www.edou.com
 * @version 1.0
 */
@Service("sysTagServiceImpl")
@Transactional(value = "transactionManager")
public class SysTagServiceImpl implements ISysTagService{

	@Resource(name = "sysTagDaoImpl")
	private ISysTagDao sysTagDao;

	/**
	 * 查询所有标签
	 */
	public List<SysTag> listSysTagAll(){
		return sysTagDao.listSysTagAll();
	}

	/**
	 * 分页查询
	 * @param pageResult 分页对象
	 * @param condition 查询条件类
	 */
	public void listSysTagByPage(PageResult<SysTag> pageResult,SysTagCondition condition){
		int rows = sysTagDao.listSysTagByPageCount(condition);
		pageResult.setRows(rows);

		RowBounds rowBounds = new RowBounds(pageResult.getCurrentPageIndex(),pageResult.getPageSize());
		List<SysTag> list = sysTagDao.listSysTagByPage(rowBounds,condition);
		pageResult.setResult(list);
	}

	/**
	 * 根据ID查询
	 * @param id 主键
	 * @return 标签
	 */
	public SysTag getSysTagById(Long id){
		return sysTagDao.getSysTagById(id);
	}

	/**
	 * 新增
	 * @param item 标签
	 */
	public void add(SysTag item){
		sysTagDao.add(item);
	}

	/**
	 * 修改
	 * @param item 标签
	 */
	public void update(SysTag item){
		sysTagDao.update(item);
	}

	/**
	 * 根据ID集合批量删除
	 * @param ids ID集合
	 */
	public void delByIds(Long[] ids){
		sysTagDao.delByIds(ids);
	}
	
	/**
	 * 根据Name查询
	 */
	@Override
	public SysTag getSysTagByName(String name) {
		return sysTagDao.getSysTagByName(name);
	}

	@Override
	public List<SysTag> listHotTag() {
		return sysTagDao.listHotTag();
	}

}

